home *** CD-ROM | disk | FTP | other *** search
-
- #####################################################################
- #####################################################################
- ## ##
- ## BOOK TOC VIEW CREATION ##
- ## ##
- #####################################################################
- #####################################################################
-
- dwScript Generic__BookTocView {
-
- ## Set password for -key books.
- ##
- dwSetKey [dwGetParam BookPassword]
-
- ## Always try to go to first hit from the TOC.
- dwSet State__NoAutoHit 0
-
- ## If the scroll position will be different from the hilite
- ## position (a path would be passed in the URL as 'tl=<path>')
- ## change the selection path now.
- ##
- dwSet HilitePath [dwGetSelectionPath]
- if {([dwGet State__TocLoc] != "") &&
- ([dwGet HilitePath] != [dwGet State__TocLoc])} {
- dwSetSelectionPath $State__TocLoc
- dwInitTocLineGenerator [dwGet State__TocDepth] [dwGet State__TocStyle]
- if {$HilitePath == ""} {
- ## Hilite the root.
- dwSet HilitePosition 0
- } else {
- ## Look for a match with the "hilite path"
- dwSet HilitePosition -2
- }
- } else {
- dwInitTocLineGenerator [dwGet State__TocDepth] [dwGet State__TocStyle]
- dwSet HilitePosition [dwGetSelectedTocItemPosition]
- if {$HilitePosition == ""} {dwSet HilitePosition 0}
- }
-
- ## We hilite the line corresponding to what the content frame
- ## is now showing. When this script is entered, the current
- ## selection path corresponds to the content frame location.
- ##
- ## Highlight the root if indicated.
- ##
- if {$HilitePosition == 0 || $HilitePosition == -1} {
- dwSet TocTitleBefore \
- "<NOBR><TABLE CELLPADDING=2 border=0><TR><TD bgcolor=#C0D8FF>"
- dwSet TocTitleAfter "</TABLE></NOBR>"
- } else {
- dwSet TocTitleBefore ""
- dwSet TocTitleAfter ""
- }
-
- ## Now compute the position in the TOC to scroll to so the selected
- ## item is visible. A simple algorithm: scroll to 10 lines before
- ## the selected item.
- ##
- set selectedPosition [dwGetSelectedTocItemPosition]
- if {$selectedPosition == ""} {set selectedPosition -1}
- if {$selectedPosition < 10} {
- dwSet TopScrollPoint "<A NAME=X></A>"
- dwSet ScrollPosition ""
- } else {
- dwSet TopScrollPoint ""
- dwSet ScrollPosition [expr $selectedPosition - 10]
- }
-
- ## Some buttons want to know what we are currently displaying
- dwSet ShowingTocView 1
-
- ## We have different templates for this page based on whether
- ## or not things are being displayed in frames.
- ##
- if {[dwGet State__Frames] == 1} {
- if {[dwGet State__UpdateOtherFrames] != 0} {
- dwCall dwMakeUrlParts
- dwSet JavaScript__UpdateBBarFrame \
- "parent.dynaweb_bbar.location=\"[dwGet RootAbsUrlPath]/@Generic__BookButtonBarView/[dwGetSelectionPath][dwGet UrlParamString][dwGet UrlQueryString]\""
- } else {
- dwSet JavaScript__UpdateBBarFrame ""
- }
- dwProcessTemplate Frames__BookTocView
- } else {
- dwProcessTemplate NoFrames__BookTocView
- }
- }
-
- dwTemplate Frames__BookTocView {
- $[dwCall dwMakeUrlParts]
- <HTML>
- <HEAD>
- <TITLE>$[dwGetRootTitle]: Table of Contents</TITLE>
- <BASE HREF="$[dwGet BaseUrl]@Generic__BookTocView">
- <SCRIPT Language="JavaScript">
- <!--
- $[dwGet JavaScript__UpdateBBarFrame]
- // -->
- </SCRIPT>
- </HEAD>
- <BODY BGCOLOR=#FFFBF0 LINK=#000000 ALINK=#008000 VLINK=#800080>
- $[dwGet TopScrollPoint]
- $[dwGet TocTitleBefore]<H3>$[dwGetRootTitle]</H3>$[dwGet TocTitleAfter]
- $[dwCall Generic__ShowSearchResult]
- <HR>
- $[dwCall Generic__GenerateBookTocViewBody]
- <HR>
- </BODY>
- </HTML>
- }
-
- dwTemplate NoFrames__BookTocView {
- $[dwCall dwMakeUrlParts]
- $[dwSet foo [dwGet UrlParamString]]
- <HTML>
- <HEAD>
- <TITLE>$[dwGetRootTitle]: Table of Contents</TITLE>
- <BASE HREF="$[dwGet BaseUrl]@Generic__BookTocView">
- </HEAD>
- <BODY BGCOLOR=#FFFBF0 LINK=#000000 ALINK=#008000 VLINK=#800080>
- $[dwGet TopScrollPoint]
- $[dwCall Generic__BookButtonBarView]
- $[dwGet TocTitleBefore]<H3>Table of contents for $[dwGetRootTitle]</H3>$[dwGet TocTitleAfter]
- $[dwCall Generic__ShowSearchResult]
- <HR>
- $[dwCall Generic__GenerateBookTocViewBody]
- <HR>
- </BODY>
- </HTML>
- }
-
- dwScript Generic__GenerateBookTocViewBody {
- if {[dwGetTocNumEntries] == 0} {
- set ret {<p><i>[No lines generated.]</i>}
- } else {
- dwCall Generic__GenerateBookTocLines
- }
- }
-
- dwScript Generic__GenerateBookTocLines {
- dwCall dwMakeUrlParts
- while {[dwNewTocLine]} {
-
- dwSet ScrollAnchor ""
- set scrollpos [dwGet ScrollPosition]
- if {$scrollpos != ""} {
- if {$scrollpos <= [dwGetTocItemPosition]} {
- dwSet ScrollPosition ""
- dwSet ScrollAnchor " NAME=X"
- }
- }
-
- dwSet TocLineIsHilited 0
- if {[dwGet HilitePosition] == -2} {
- if {[dwGet HilitePath] == [dwGetTocItemPath]} {
- dwSet TocLineIsHilited 1
- }
- } elseif {[dwGet HilitePosition] == [dwGetTocItemPosition]} {
- dwSet TocLineIsHilited 1
- }
-
- set query [dwGet UrlQueryString]
- regsub -all {\<} $query {\<} query
- regsub -all {\>} $query {\>} query
-
- # if there are hits, goto first hit
- set first_search_hit ""
- set nhparam ""
- if {[dwGetTocItemHitCount] > 0} {
- set first_search_hit "#1"
- if {[dwGetTocItemState] != "expandable"} {
- set nhparam ";nh=1"
- }
- }
-
- if {[dwGet State__Frames] == 1} {
- set params [dwGet UrlParamString]
-
- set textpath "@Generic__BookTextView/[dwGetTocItemPath]"
- dwSet TocLineUrl "$textpath$params$nhparam$query$first_search_hit"
-
- set tocpath "@Generic__BookTocView/[dwGet HilitePath]"
- set tlparam ";tl=[dwGetTocItemPath]"
- dwSet TocIconUrl "$tocpath$tlparam$params$query#X"
-
- set tlparam ";tl=[dwGetTocItemExpansionPath]"
- dwSet TocIconExpUrl "$tocpath$tlparam$params$query#X"
-
- dwSet TocLineTarget " TARGET=\"dynaweb_content\""
- dwSet TocIconTarget " TARGET=\"dynaweb_toc\""
- } else {
- set params [dwGet UrlParamString]
- set textpath "@Generic__BookTextView/[dwGetTocItemPath]$nhparam"
- set tocpath "@Generic__BookTocView/[dwGetTocItemPath]"
- set exppath "@Generic__BookTocView/[dwGetTocItemExpansionPath]"
- dwSet TocLineUrl "$textpath$params$query$first_search_hit"
- dwSet TocIconUrl "$tocpath$params$query#X"
- dwSet TocIconExpUrl "$exppath$params$query#X"
- dwSet TocIconTarget ""
- dwSet TocLineTarget ""
- }
- dwCall Tables__ShowCurrentTocLine
- }
- }
-
-